package org.code.constanQue;

public class ImplConstQue {
	public int Que[];
	public int ele_cnt;
	public int pushIdx;
	public int popIdx;
	public ImplConstQue(int size) {
		Que = new int[size];

	}
	public int getSize(){
		return ele_cnt;

	}

	public void push(int val) throws Exception {
		if (ele_cnt < Que.length) {
			Que[pushIdx] = val;
			pushIdx = (pushIdx+1) % Que.length;
			ele_cnt++;
		} else {
			throw new Exception(" queue is full fool no space for new element bay");
		}
	}
	public int pop() throws Exception {
		if (ele_cnt > 0) {
			int elem = Que[popIdx];			
			popIdx = (popIdx+1) % Que.length;
			ele_cnt--;
			return elem;
		} else {
			throw new Exception("Hey Stupid Queue is Empty bay");
		}
	}
	public static void main(String args[]) {
		try {
			ImplConstQue q = new ImplConstQue(1);
			q.push(100);
			q.push(200);
			System.out.println(q.pop());
			System.out.println(q.getSize());

		} catch (Exception e) {
			e.printStackTrace();
		}

	}
}
